import { Component, OnInit } from '@angular/core';
import { WithdrawService } from './withdraw.service'
import { DataService } from '../../../../../services/data.service';

@Component({
  selector: 'app-withdraw',
  templateUrl: './withdraw.component.html',
  styleUrls: ['./withdraw.component.scss'],
  providers: [WithdrawService]
})
export class WithdrawComponent implements OnInit {
  //modal创建时传值
  public item: any;

  constructor(
    public withdrawService: WithdrawService,
    public dataService: DataService
  ) { }

  ngOnInit() {
  }

  //撤销
  withdraw() {
    let putBody: any = {
      nFgId: this.item.nFgId,
      sType: this.item.sType,
      sFgName: this.item.sFgName,
      sFgDesc: this.item.sFgDesc,
      sFgMemberValid: this.item.sFgMemberValid,
      sMemberTemp: this.item.sMemberTemp,
      // sStatus: this.sStatus,
    }
    console.log(putBody)
    this.withdrawService.withdraw(this.item.sType, putBody).subscribe(data => {
      if (data) {
        this.dataService.rcmiEditEmitter.emit('withdraw');
        window['swal']("成功", "撤销成功", "success");
      }
    });
  }
  // 关闭modal时解锁
  closeModal() {
    let getbody = {
      nFgIdList: []
    }
    getbody.nFgIdList.push(this.item.nFgId)
    this.withdrawService.unlock(getbody).subscribe((data) => {
    })
  }

}
